//
//  HHPTableViewCellModel.m
//  HHPTableViewManager
//
//  Created by 韩红坡 on 2017/3/8.
//  Copyright © 2017年 韩红坡. All rights reserved.
//

#import "HHPTableViewCellModel.h"

@interface HHPTableBlankCell : UITableViewCell

@end

@implementation HHPTableBlankCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

@end

@implementation HHPRowActionModel

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.actionStyle = UITableViewRowActionStyleDefault;
    }
    
    return self;
}

@end

@interface HHPTableViewCellModel ()

@property (nonatomic, weak) HHPTableViewSectionModel *sectionModel;

@property (nonatomic, assign) Class _cellClass;
@property (nonatomic, assign) CGFloat _cellHeight;
@property (nonatomic, strong) NSMutableArray<HHPRowActionModel *> *_rowActionModelArray;

@end

@implementation HHPTableViewCellModel

+ (instancetype)cellModelWithClass:(Class)classname height:(CGFloat)height
{
    HHPTableViewCellModel *instance = [[self alloc] init];
    if (instance) {
        instance._cellClass = classname;
        instance._cellHeight = height;
        instance.cellActionEnabled = NO;
        instance._rowActionModelArray = [NSMutableArray array];
    }
    return instance;
}

+ (instancetype)blankCellModel
{
    return [HHPTableViewCellModel blankCellModelWithHeight:12];
}

+ (instancetype)blankCellModelWithHeight:(CGFloat)height
{
    return [HHPTableViewCellModel cellModelWithClass:[HHPTableBlankCell class] height:height];
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.autoDeselect = YES;
        self.cellActionEnabled = YES;
    }
    return self;
}

- (Class)cellClass
{
    return self._cellClass;
}

- (CGFloat)cellHeight
{
    return self._cellHeight;
}

- (NSMutableArray<HHPRowActionModel *> *)rowActionModelArray
{
    return __rowActionModelArray;
}

@end
